package thread;

class MyThread extends Thread {
    //重写 run 方法
    // run 代表线程的入口，线程运行起来后，要执行啥样的逻辑

    @Override
    public void run() {
        while(true) {
            System.out.println("Hello thread");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}
public class Demo1 {
    public static void main(String[] args) throws InterruptedException {
        //使用这个线程
        MyThread myThread = new MyThread();
        myThread.start();

        while(true) {
            System.out.println("Hello world");
            Thread.sleep(1000);
        }
    }
}
